<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.8.2.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#happyMoneyBtn").click(function(){
			window.open("happytime/happy_money.jsp","","resizable=true,toolbar=no,width=280,height=170");
		});
		$("#checkId").click(function() {
			if(${sessionScope.mvo==null }){
				alert("로그인 하고 오세요 ");
				return false;
			}//if
			else{
				$.ajax({
					type : "POST",
					url : "album.do",
					data : "command=idcheck&optionalNoTest=${requestScope.optionalNoTest }",
					success : function(data) {
						if(data.flag==false){
							alert("이방 주인만 파일 올리기 가능합니다 ");
							return;
						}//if문
						else{
							alert("사진 가능")
							$("#fileform").submit();
						}//else문
					} // success
				}) // ajax
				
			}//세션 아이디 
		}) // checkId click
	}) // document ready

</script>
</head>
<body>
<img src="${initParam.root}/img/album_top.gif"><br><br>
<table border="4" cellspacing="15" cellpadding="5" align="center">
<tr>
<c:forEach items="${requestScope.happyList.list }" var="i" varStatus="no">
<td><img src="${initParam.root}/happytimealbum/happyimg/${i.newfilename }" width="150" height="160" id="coupleImg"></td>
<c:if test="${no.count%4==0}"><tr></tr></c:if>
</c:forEach>
</table>

<table align="center">
<tr>
<td>
<c:if test="${requestScope.happyList.pagingBean.previousPageGroup}">
	<a href="${initParam.root}/album.do?command=HappyTimeAlbumList&page=${requestScope.happyList.pagingBean.startPageOfPageGroup-1}&optionalNoTest=${requestScope.optionalNoTest }">
	<img src="${initParam.root}/img/left_arrow_btn.gif"></a>
	</c:if>
	
	<c:forEach var="i" begin="${requestScope.happyList.pagingBean.startPageOfPageGroup}" end="${requestScope.happyList.pagingBean.endPageOfPageGroup}">
	<c:choose>
	<c:when test="${requestScope.happyList.pagingBean.nowPage!=i}">
	<a href="${initParam.root}/album.do?command=HappyTimeAlbumList&page=${i}&optionalNoTest=${requestScope.optionalNoTest }">${i}</a>
	</c:when>
	<c:otherwise>
	${i}
	</c:otherwise>
	</c:choose>
	</c:forEach>	 
	 
	<c:if test="${requestScope.happyList.pagingBean.nextPageGroup}">
	<a href="${initParam.root}/album.do?command=HappyTimeAlbumList&page=${requestScope.happyList.pagingBean.endPageOfPageGroup+1}&optionalNoTest=${requestScope.optionalNoTest }">
	<img src="${initParam.root}/img/right_arrow_btn.gif"></a>
	</c:if>
	<br>
</td>
</tr>
</table><br>

	<form action="${initParam.root}/upload.do" method="post" enctype="multipart/form-data" id="fileform">
	<input type="hidden" name="command" value="albumUpload">
	<input type="hidden" name="optionalNoTest" value="${requestScope.optionalNoTest }">
	<span style="margin-left: 550px"><input type="file" name="uploadFile" >
	<input type="button" value="전송" id="checkId"></span><br><br>
	<img src="${initParam.root}/img/money_send.gif" id="happyMoneyBtn" style="margin-left: 350px">
</form>
	
</body>
</html>